<template>
  <el-dialog title="修改FAQ"
             :visible.sync="visible"
             @close="handleCancelEdit">
    <el-form :model="updateTemp" ref="updateTemp">
      <el-form-item label="问题描述" prop="question">
        <el-input v-model="updateTemp.question" type="text" placeholder="请输入问题描述">
        </el-input>
      </el-form-item>
      <div class="editor-container" style="margin-bottom: 20px">
        <p class="__label">解答</p>
        <tinymce :height=400
                 ref="editor"
                 :init = "initContent"
                 id="introduce-edit-update"
                 v-model="updateTemp.answer"
        ></tinymce>
      </div>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button v-waves @click="handleCancelEdit">取消</el-button>
      <el-button v-waves type="primary" @click="handleUpdateData">提交</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import Tinymce from '@/components/Tinymce'
  import waves from '@/directive/waves/index.js'

  export default {
    name: 'update-dialog',
    components: {
      Tinymce
    },
    data() {
      return {
        visible: false,
        dialogVisible: false
      }
    },
    directives: {
      waves
    },
    props: {
      updateTemp: Object,
      dialogUpdateFormVisible: Boolean,
      initContent: Boolean
    },
    watch: {
      dialogUpdateFormVisible(val) {
        this.visible = val
      }
    },
    methods: {
      handleCancelEdit() {
        this.visible = false
        this.$emit('cancel', this.visible)
      },
      handleUpdateData() {
        this.$emit('update')
      }
    }
  }
</script>

<style scoped>

</style>
